// 引入自定义分页组件
import CharlieLoading from "@/components/Loading.vue";
 
export default {
    // 全局挂载
  install(Vue) {
    //   挂载为全局组件
    Vue.component("CharlieLoading", CharlieLoading);
    // 自定义拖拽指令
    Vue.directive('drag', {
      inserted:function(el){
        // 设置样式
        el.style.position = 'absolute';
        el.style['-webkit-user-select'] = 'none';
        el.style['-ms-user-select'] = 'none';
        el.style['-moz-user-select'] = '-moz-none';
        el.style.cursor = 'pointer';
        // 事件监听
        el.onmousedown=function(e){
            let l=e.clientX-el.offsetLeft;
            let t=e.clientY-el.offsetTop;
            document.onmousemove=function(e){
                el.style.left=e.clientX-l+'px';
                el.style.top=e.clientY-t+'px';
            };
            el.onmouseup=function(){
                document.onmousemove=null;
                el.onmouseup=null;
            }
        }
      }
    });
    // 自定义节流按钮指令
    Vue.directive('pre4',{
			inserted(button){
                // 事件监听
				button.addEventListener('click',()=>{
					if(!button.disabled){
						button.disabled = true;
						setTimeout(()=>{
							button.disabled = false
						},1000)
					}
				})
			}
		});
 
  }
};